package com.bysc.cmsservice.factory;

import com.bysc.cmsservice.caller.AiCaller;
import com.bysc.cmsservice.caller.BaiDuAiCaller;
import com.bysc.cmsservice.caller.KimiAiCaller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class AiCallerFactory {
    @Autowired
    private BaiDuAiCaller baiduAiCaller;
    @Autowired
    private KimiAiCaller kimiAiCaller;

    private Map<String, AiCaller> callerMap = new HashMap<>();

    @Autowired
    public void init() {
        // 注册不同的AI调用器
        callerMap.put("baidu", baiduAiCaller);
        callerMap.put("kimi", kimiAiCaller);
    }

    public AiCaller getAiCaller(String type) {
        AiCaller caller = callerMap.get(type);
        if (caller == null) {
            throw new IllegalArgumentException("Unknown AI type: " + type);
        }
        return caller;
    }
}